<template>
  <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo" placeholder="请输入任务名称" autofocus v-model.trim="value" @keyup.enter="AddList"/>
  </header>
</template>

<script>
export default {
  data(){
    return {
      value:''
    }
  },
  methods:{
    // 键盘按下回车，触发添加
    AddList(){
      this.value === '' ? alert('内容不能为空') : this.$emit('AddList',this.value)
      this.value = ''
    }
  }
}
</script>

<style></style>
